<template>
  <div v-if="isShow" class="notice-box">
    <h3>{{title}}</h3>
    <p>{{message}}</p>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      default: ''
    },
    message: {
      type: String,
      default: ''
    },
    duration: {
      type: Number,
      default: 0
    }
  },
  data(){
    return {
      isShow: false
    }
  },
  methods: {
    show(){
      this.isShow = true
      setTimeout(() => {
        this.hide()
      }, this.duration)
    },
    hide(){
      this.isShow = false
      this.remove()
    }
  }
}
</script>

<style scoped>
.notice-box {
  position: fixed;
  width: 500px;
  padding: 20px;
  background: #FFF;
  border: 1px solid #333;
  border-radius: 20px;
  box-shadow: 4px 4px 5px #888;
  left: 50%;
  margin-left: -250px;
  top: 20px;
}
</style>